<template>
    <view class="page">
		<view>
			 <aloys-tab :tabs="tabs" @change="onTabChange">
			 </aloys-tab>
		</view>
		 <view v-for="(item, index) in list" :key="index">
			<view class="flex" @click="toDetail(item)">
				<view class="fangk-shape display_flex_column">
					<view class="top-line flex">
						<text class="shangjia-name">{{item.name}}</text>
						<!-- <text class="order-status">{{item.stateCn}}</text> -->
					</view>
					<view class="line"/>
					<view class="second-line display_flex_column">
						<view class="info-item flex">
							<text class="info-name">收货人:</text>
							<text class="info-content">{{item.addrInfo.name}}</text>
						</view>
						<view class="info-item flex">
							<text class="info-name">收货地址:</text>
							<text class="info-content">{{item.addrInfo.areaName}}{{item.addrInfo.addrName}}</text>
						</view>
						
						<view class="info-item flex">
							<text class="info-name">收货人电话:</text>
							<text class="info-content">{{item.addrInfo.mobile}}</text>
						</view>
						<!-- <view class="info-item flex">
							<text class="info-name">预约时间:</text>
							<text class="info-content">{{item.subscribeTime}}</text>	
						</view>
						<view  class="line-last flex" v-if="item.state=='YWC'">
						     <button  class="button" type="default" @click.stop="evaluate(item)">评价</button>
						</view> -->
					</view>
				</view>
			</view>
		</view>
		<view style="margin-top: 120rpx; color: #999;"><uni-load-more :status="status" :content-text="contentText" /></view>
		<auth/>
    </view>
</template>

<script>
import { getPrizeGoodsPage } from "../../service/base"	
import aloysTab from "@/components/aloys-tab/aloys-tab.vue"	
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
export default {
	components:{ 
		   aloysTab,
		   uniLoadMore
	},
    data() {
        return {
			orderStatus:'',
			status : 'loading',
			contentText: {
							contentdown: '上拉加载更多',
							contentrefresh: '加载中',
							contentnomore: '没有更多'
						},
            activeIndex: 0,
			stateList: ['WJD'],
			 tabs: [{
				title: '全部'
			  },{
				title: '待发货'
			  },{
			  	title: '已发货'
			  },{
				title: '已完成'
			  }],
			  list: [],
			  isLastPage: false,
			  pageNum: 1,
			  openid:'',
			  shipmentstatus: null
        }
    },
	onShow(){
		this.list = []
		this.pageNum = 1
		this.getPrizeGoodsPage()
	},
	onReachBottom: function() {
		console.log('加载中')
		if(!this.isLastPage){
			this.status = 'more';
			this.pageNum ++ ;
			this.getPrizeGoodsPage()
		}
	},
    methods: {
		toChinaStatus(state){
			return state == 'WJD' ? '未接单' : state == 'DHS'? '已接单': state == 'YHS'?'已接单'
			     : state == 'YWC' ? '待评价' : state == 'DDB'? "已接单" :"已完成"
		},
		toDetail(item){
			uni.setStorageSync('MyAddOrderDataDetail',JSON.stringify(item))
			uni.navigateTo({
				url:"/pages/classify/detail"
			})
		},
		 onTabChange(index) {
			  this.list = []
			  this.pageNum = 1
			 if(index == 0){
				 this.shipmentstatus = null
			 }else if(index == 1){
				  this.shipmentstatus = 1
			 } else if(index == 2){
				 this.shipmentstatus = 2
			 } else if(index == 3){
			 	 this.shipmentstatus = 3
			 }else {
				 this.shipmentstatus = null
			 }
			 this.getPrizeGoodsPage()
		},
		getPrizeGoodsPage() {
			 this.status = 'loading';   
			getPrizeGoodsPage({shipment_status: this.shipmentstatus,pageNum:this.pageNum}).then(res => {
				  this.isLastPage =  res.data.isLastPage
				  if(res.data.list){
					  res.data.list.forEach(item => {
						  item.stateCn = this.toChinaStatus(item.state)
						  this.list.push(item)
					  })
					  console.log(this.list)
				  }
				  if(this.isLastPage){
					 this.status = 'noMore';     
				  }
			})
		},
		evaluate(item){
					uni.navigateTo({
						url: "./evaluate?ecyOppenId=" + item.oprOpenid+ "&orderId="+ item.id
					});
		},
    },
}
</script>

<style lang="less">
	@import "./index";
	page{
		background: #f8f9f8;
		height: 100%;
	}
</style>
